package com.service.business.pay.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.service.business.pay.controller.rep.PayTypeRep;
import com.service.business.pay.service.PayTypeService;
import com.service.dao.enums.CommonStatusEnums;
import com.service.dao.mapper.PayTypeMapper;
import com.service.dao.model.PayType;
import com.service.utility.modelmapper.ModelMapperUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;


@Service("payTypeService")
public class PayTypeServiceImpl extends ServiceImpl<PayTypeMapper, PayType> implements PayTypeService {

    @Override
    public List<PayTypeRep> listByPayGroup(Integer payGroup) {
        return list(new QueryWrapper<PayType>().lambda()
                .eq(PayType::getPayGroup, payGroup)
                .eq(PayType::getPayStatus, CommonStatusEnums.ACTIVE.getCode())).stream()
                .map(item -> ModelMapperUtil.getStrictModelMapper().map(item, PayTypeRep.class))
                .collect(Collectors.toList());
    }
}
